package com.titar.robot.widgets;


import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;

/**
 * @desc：正方形的ImageView
 */
public class SquesImageView extends ImageView {
    private static final String TAG = "SquesImageView";

    public SquesImageView(Context context) {
        this(context, null);
    }

    public SquesImageView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public SquesImageView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int width = MeasureSpec.getSize(widthMeasureSpec);
        int height = MeasureSpec.getSize(heightMeasureSpec);

        int size = Math.min(width, height);
        int sizeMeasureSpec = MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY);
        super.onMeasure(sizeMeasureSpec, sizeMeasureSpec);
    }
}
